package cn.virens.common.easyexcel;

import cn.idev.excel.EasyExcel;
import cn.idev.excel.read.builder.ExcelReaderBuilder;
import org.dromara.hutool.core.io.file.FileUtil;

public class ExcelImportWork implements AutoCloseable {
    private final ExcelImportExecutor<?> executor;
    private final ExcelReaderBuilder builder;

    public ExcelImportWork(ExcelImportExecutor<?> executor, Class<?> clazz) {
        this.builder = EasyExcel.read(executor.temp, clazz, executor);
        this.executor = executor;
    }

    @Override
    public void close() throws RuntimeException {
        FileUtil.del(executor.temp);
    }

    public ExcelReaderBuilder builder() {
        return builder;
    }
}
